package com.appleword.biz.book.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.appleword.common.annotation.Log;
import com.appleword.common.core.controller.BaseController;
import com.appleword.common.core.domain.AjaxResult;
import com.appleword.common.enums.BusinessType;
import com.appleword.biz.book.domain.ApplewordBookGroup;
import com.appleword.biz.book.service.IApplewordBookGroupService;
import com.appleword.common.utils.poi.ExcelUtil;
import com.appleword.common.core.page.TableDataInfo;

/**
 * 书籍分组Controller
 * 
 * @author apple
 * @date 2024-05-13
 */
@RestController
@RequestMapping("/book/bookgroup")
public class ApplewordBookGroupController extends BaseController
{
    @Autowired
    private IApplewordBookGroupService applewordBookGroupService;

    /**
     * 查询书籍分组列表
     */
    @PreAuthorize("@ss.hasPermi('book:bookgroup:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplewordBookGroup applewordBookGroup)
    {
        startPage();
        List<ApplewordBookGroup> list = applewordBookGroupService.selectApplewordBookGroupList(applewordBookGroup);
        return getDataTable(list);
    }

    /**
     * 导出书籍分组列表
     */
    @PreAuthorize("@ss.hasPermi('book:bookgroup:export')")
    @Log(title = "书籍分组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApplewordBookGroup applewordBookGroup)
    {
        List<ApplewordBookGroup> list = applewordBookGroupService.selectApplewordBookGroupList(applewordBookGroup);
        ExcelUtil<ApplewordBookGroup> util = new ExcelUtil<ApplewordBookGroup>(ApplewordBookGroup.class);
        util.exportExcel(response, list, "书籍分组数据");
    }

    /**
     * 获取书籍分组详细信息
     */
    @PreAuthorize("@ss.hasPermi('book:bookgroup:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(applewordBookGroupService.selectApplewordBookGroupById(id));
    }

    /**
     * 新增书籍分组
     */
    @PreAuthorize("@ss.hasPermi('book:bookgroup:add')")
    @Log(title = "书籍分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplewordBookGroup applewordBookGroup)
    {
        return toAjax(applewordBookGroupService.insertApplewordBookGroup(applewordBookGroup));
    }

    /**
     * 修改书籍分组
     */
    @PreAuthorize("@ss.hasPermi('book:bookgroup:edit')")
    @Log(title = "书籍分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplewordBookGroup applewordBookGroup)
    {
        return toAjax(applewordBookGroupService.updateApplewordBookGroup(applewordBookGroup));
    }

    /**
     * 删除书籍分组
     */
    @PreAuthorize("@ss.hasPermi('book:bookgroup:remove')")
    @Log(title = "书籍分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(applewordBookGroupService.deleteApplewordBookGroupByIds(ids));
    }
}